<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AdRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|between:1,100',
            'link' => 'required|url',
            'color' => 'required',
            'border_color' => 'required',
            'size' => 'required|numeric|min:8|max:72',
            'show_border' => 'boolean'
        ];
    }

    public function messages()
    {
        return [
            'title.required' => '请填写广告语',
            'title.between' => '广告语必须在 1-100个字符之间',
            'link.required'  => '请填写广告链接',
            'link.url' => '广告链接格式不正确！',
            'color.required' => '请填写字体颜色',
            'border_color.required' => '请填写边框颜色',
            'size.required' => '请填写字体大小',
            'size.numeric' => '字体大小必须是数字',
            'size.min' => '字体大小不能小于 8',
            'size.max' => '字体大小不能大于72',
            'show_border.boolean' => '提交的参数有误！'
        ];
    }
}
